home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 37
/
Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso
/
Aminet
/
dev
/
asm
/
fastsincos.lha
/
fastsincos
/
fastasin.asm
< prev
next >
Wrap
Assembly Source File
|
2000-04-12
|
2KB
|
151 lines
incdir asm:
include exec/execbase.i
include math.i
include phxmacros.i
mc68040
xref _SysBase
xref _exit
EXTERN_LIB AllocVec
EXTERN_LIB FreeVec
dasin
fcmp.d #1,fp0
fbne .cont
fmove.d #1e5,fp0
rts
.cont
fmove.d #1,fp1
fmul.x fp0,fp0
fsub.x fp0,fp1
fsqrt.x fp1
fmove.d #1,fp0
fdiv.x fp1,fp0
rts
xdef _INIT_1_FastASin
_INIT_1_FastASin
move.l _SysBase,a6
move.w AttnFlags(a6),d0
btst #AFB_68040,d0
beq .ret
move.l #24*9999,d0
moveq #0,d1
callsys AllocVec
move.l d0,asintab
beq .exit
move.l d0,a0
moveq #0,d0
moveq #1,d1
.loop
fmove.w d0,fp2
fmul.d #1e-4,fp2
fmove.w d1,fp3
fmul.d #1e-4,fp3
fmove.x fp2,fp4
fasin.x fp4 ;y
;p->a=(dasin(x1)-dasin(x))*20000;
fmove.x fp3,fp0
bsr dasin
fmove.x fp0,fp5
fmove.x fp2,fp0
bsr dasin
fsub.x fp0,fp5
fmul.d #20000,fp5
fmove.d fp5,(a0)+
;p->b=(asin(x1)-y)*10000-p->a*(2*x+1e-4);
fasin.x fp3
fsub.x fp4,fp3
fmul.d #10000,fp3
fmove.x fp2,fp0
fadd.x fp0,fp0
fadd.d #1e-4,fp0
fmul.x fp5,fp0
fsub.x fp0,fp3
fmove.d fp3,(a0)+
;p->c=y-(p->a*x+p->b)*x;
fmul.x fp2,fp5
fadd.x fp3,fp5
fmul.x fp2,fp5
fsub.x fp5,fp4
fmove.d fp4,(a0)+
inc.w d1
inc.w d0
cmp.w #9999,d0
blo .loop
.ret
rts
.exit
pea 20
jsr _exit
xdef _EXIT_1_FastASin
_EXIT_1_FastASin
move.l asintab,a1
callsys FreeVec,SysBase
rts
asintab
dc.l 0
xdef fastasin___r_d
xdef _fastasin__r
fastasin___r_d
_fastasin__r
pushm.l d0/a0
fmove.d 12(sp),fp0
bsr fastasin
popm.l d0/a0
rts
xdef fastasin
fastasin
fpush.x fp1
fpush.x fp0
fabs.x fp0
fcmp.d #1,fp0
fble .cont
fmove.d #PI2,fp0
bra .contx
.cont
fmove.x fp0,fp1
fmul.d #10000,fp0
fintrz.x fp0 ;This one is required. Dont skip it !
fmove.w fp0,d0
cmp.w #9999,d0
blo .cont1 ;Avoid infinty
fpop.x fp0
fasin.x fp0
fpop.x fp1
rts
.cont1
mulu.w #24,d0
move.l asintab,a0
add.l d0,a0
fmove.d (a0)+,fp0
fmul.x fp1,fp0
fadd.d (a0)+,fp0
fmul.x fp1,fp0
fadd.d (a0),fp0
.contx
fpop.x fp1
fbge .cont2
fneg.x fp0
.cont2
fpop.x fp1
rts